/* 
    news
    JavaScript functions
 */

function exibirNews(index){
    document.getElementById("news_panel").innerHTML = news_html[index];
}
            
function prevNews(){
    news_index--;
    if(news_index < 1){
        news_index = news_qtd;
    }
    exibirNews(news_index);
}
            
function nextNews(){
    news_index++;
    if(news_index > news_qtd){
        news_index = 1;
    }
    exibirNews(news_index);
}
            
function newsTimer(){
    if(news_qtd == 0){
        exibirNews(0);
    }else{
        if(news_qtd == 1){
            exibirNews(1);
        }else{
            exibirNews(1);
            setInterval(
                function(){
                    if(mouse_over == false){
                        news_index++;
                        if(news_index > news_qtd){
                            news_index = 1;
                        }
                        exibirNews(news_index);
                    }
                },5000);
        }
    }
}

function mouseOverNews(){
    mouse_over = true;
    document.getElementById("news_status").src = "img/stop.png";
}

function mouseOutNews(){
    mouse_over = false;
    document.getElementById("news_status").src = "img/play.png";
}